local function Radio( ply, cmd, text )

	if( not ply:HasItem( "radio" ) ) then return end

	if( ply:GetPlayerRadioFreq() == 0 ) then
		ply:PrintMessage( 3, "Must have a frequency greater than 0!" )
		return
	end	

	ply:RadioTalk( "[@" .. ply:GetPlayerRadioFreq() .. "] - " .. ply:GetRPName() .. ": " .. text )
	ply:SendToStationRadio( text );
	ply:SayLocalChat( text )

end
TS.ChatCmd( "/r", Radio );
TS.ChatCmd( "/radio", Radio );

local function RadioYell( ply, cmd, text )

	if( not ply:HasItem( "radio" ) ) then return end

	ply:RadioTalk( "[@" .. ply:GetPlayerRadioFreq() .. "] - " .. ply:GetRPName() .. " - [Y]:" .. text )
	ply:YellLocalChat( text )
	
end	
TS.ChatCmd( "/ry", RadioYell );
TS.ChatCmd( "/yw", RadioYell );

local function RadioW( ply, cmd, text )

	if( not ply:HasItem( "radio" ) ) then return end

	ply:RadioTalk( "[@" .. ply:GetPlayerRadioFreq() .. "] - " .. ply:GetRPName() .. " - [w]:" .. text )
	ply:WhisperLocalChat( text )
	
end	
TS.ChatCmd( "/wr", RadioW );
TS.ChatCmd( "/radiowis", RadioW );

local function RadioDispatch( ply, cmd, text )

	if( not ply:HasItem( "radio" ) ) then return end

	ply:RadioTalk( "[Dispatch]" .. text )
	
end	
TS.ChatCmd( "/dr", RadioDispatch );

local function crRadio( ply, cmd, text )

	ply:TalkToCPCR( ply:GetRPName() .. " requests \"" .. text "\"" )
	ply:SayLocalChat( text )

end
TS.ChatCmd( "/cr", crRadio );

local function ooc( ply, cmd, text )

	if( CurTime() < ply:GetTable().NextTimeCanChatOOC and not ply:IsAdmin() ) then 
		return;
	end

	if( TS.OOCDelay > 0 ) then
	
		umsg.Start( "SNCTOOC", ply );
			umsg.Float( TS.OOCDelay );
		umsg.End();
	
		ply:GetTable().NextTimeCanChatOOC = CurTime() + TS.OOCDelay;
	
	end

	return text;

end
TS.ChatCmd( "/ooc", ooc );
TS.ChatCmd( "//", ooc );
TS.ChatCmd( "/a", ooc );

local function title( ply, cmd, text )
	
	if( not string.find( text, " " ) ) then return; end
	
	text = string.gsub( text, "\n", "" );
	text = string.gsub( text, "\r", "" );
	
	if( string.len( text ) > 35 ) then
	
		text = string.sub( text, 1, 35 );
	
	end
	
	ply:SetNWString( "title", string.sub( text, 2 ) );
	ply:SetPlayerTitle( string.sub( text, 2 ) );
	
	TS.CreateWhiteNotify( ply, "Title changed to " .. text )
	
	cmd = "UPDATE `characters` SET `Title` = '" .. string.sub( text, 2 ) .. "' WHERE `RPName` = '" .. ply:GetRPName() .. "'" 
	sql.Query( cmd );
	
end
TS.ChatCmd( "/title", title );

TS.CIDs = { }

local function ccSetCID( ply, cmd, text )
	
	if( ply:IsCombineDefense() ) then
		Console( ply, "You need to be citizen!", true )
		return
	end

	if( not string.find( text, " " ) ) then return end
	
	if( string.find( text, tonumber( 13337 ) ) ) then 
		Console( ply, "Can't have this number as a CID", true )
		return;
	end
	
	--[[if( tostring( ply:GetNWBool( "CID" ) ) > tostring( 0 ) ) then
		Console( ply, "Already have a CID!", true );
		return;
	end	--]]
	
	text = string.gsub( text, "\n", "" )
	text = string.gsub( text, "\r", "" )
	
	if( string.len( text ) > 6 ) then
		text = string.sub( text, 1, 6 )
	end
	
	if( TS.CIDIsTaken( string.sub( text, 2 ) ) ) then
		Console( ply, "CID already taken", true )		
		return 	
	end
	
	ply:SetNWFloat( "CID", string.sub( text, 2 ) )
	ply:SaveData( "CID", string.sub( text, 2 ) );
	
	newcid = string.sub( text, 2 )
	
	--TS1 Copy-Paste
	local function SaveCID( newcid )
		file.Write( "TS2/data/cids.txt", ( file.Read( "TS2/data/cids.txt" ) or "" ) .. newcid .. "\r\n" );
	end
	
	timer.Simple( 2, SaveCID, newcid );
	
	TS.CreateWhiteNotify( ply, "Set CID to " .. ply:GetNWBool( "CID" ) );
	
end
TS.ChatCmd( "/cid", ccSetCID )	
	
local function ccSecondTitle( ply, cmd, text )
	
	if( not string.find( text, " " ) ) then return; end
	
	text = string.gsub( text, "\n", "" );
	text = string.gsub( text, "\r", "" );
	
	if( string.len( text ) > 35 ) then
	
		text = string.sub( text, 1, 35 );
	
	end
	
	ply:SetNWString( "secondtitle", string.sub( text, 2 ) );
	ply:SetPlayerSecondTitle( string.sub( text, 2 ) );
	
	TS.CreateWhiteNotify( ply, "Second title changed to " .. text )
	
	cmd = "UPDATE `characters` SET `SecondTitle` = '" .. string.sub( text, 2 ) .. "' WHERE `RPName` = '" .. ply:GetRPName() .. "'" 
	sql.Query( cmd );
	
end
TS.ChatCmd( "/title2", ccSecondTitle );

local function getup( ply, cmd, text )

	if( not ply:GetPlayerConscious() and ply:GetPlayerConsciousness() >= 45 ) then
	
		ply:Conscious();
	
	end

end
TS.ChatCmd( "/getup", getup );

local function passout( ply, cmd, text )
	
	ply:SetPlayerConsciousness( 0 )	
	ply:Unconscious();
	
end
TS.ChatCmd( "/passout", passout );

local function ccSetClassMark( ply, cmd, text )

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	if( !ply:IsCombine() ) then
		Console( ply, "Need to be CP", true )
		return
	end	

	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	local ValidMarks = { "A", "B", "C", "D", "E", "F" }
	
	if( !tr.Entity and !tr.Entity:IsValid() and !tr.Entity:IsPlayer() ) then
		Console( ply, "You're not looking at anyone!", true )
		return
	end	
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
	
		tr.Entity:SetPlayerClassMark( text )
		tr.Entity:SaveData( "ClassMark", text )
		
		--[[umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " set your classmark to " .. text );
		umsg.End();	

		umsg.Start( "ICAction", ply );
			umsg.String( "You" );
			umsg.String( " set " .. tr.Entity:GetRPName() .. " class mark to " .. text )
		umsg.End();	--]]
		
		TS.CreateWhiteNotify( ply, "Set " .. tr.Entity:GetRPName() .. "'s classmark to " .. text )
		TS.CreateWhiteNotify( tr.Entity, ply:GetRPName() .. "has set your classmark to " .. text )
	
	end
	
end
TS.ChatCmd( "/setcm", ccSetClassMark );

local function ccSetClassStatus( ply, cmd, text )

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	if( !ply:IsCombine() ) then
		Console( ply, "Need to be CP", true )
		return
	end	

	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	if( !tr.Entity and !tr.Entity:IsValid() and !tr.Entity:IsPlayer() ) then
		Console( ply, "You're not looking at anyone!", true )
		return
	end	
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
	
		tr.Entity:SetPlayerClassStatus( text )
		tr.Entity:SaveData( "ClassStatus", text )
		
		TS.CreateWhiteNotify( ply, "Set " .. tr.Entity:GetRPName() .. "'s class status to " .. text )
		TS.CreateWhiteNotify( tr.Entity, ply:GetRPName() .. "has set your class status to " .. text )
	
	end
	
end
TS.ChatCmd( "/setcs", ccSetClassStatus );
		
local function givemoney( ply, cmd, text )

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	local val = tonumber( text )
	
	if( not val ) then return; end
	
	if( not ply:CanAfford( val ) ) then
		return;
	end
	
	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
	
		tr.Entity:GiveMoney( val );
		ply:TakeMoney( val );
		
		local plur = "s";
		
		if( val == 1 ) then
			plur = "";
		end
	
		--[[umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " gave you " .. val .. " credit" .. plur );
		umsg.End();	

		umsg.Start( "ICAction", ply );
			umsg.String( "You" );
			umsg.String( " gave " .. tr.Entity:GetRPName() .. " " .. val .. " credit" .. plur );
		umsg.End();	--]]
		
		TS.CreateWhiteNotify( ply, "You gave " .. tr.Entity:GetRPName() .. " " .. val .. "credit" .. plur )
		TS.CreateWhiteNotify( tr.Entity, ply:GetRPName() .. " gave you " .. val .. " credit" .. plur )
	
	end
	
end
TS.ChatCmd( "/give", givemoney );
TS.ChatCmd( "/givemoney", givemoney );
TS.ChatCmd( "/givecredits", givemoney );


local function yell( ply, cmd, text )

	ply:YellLocalChat( "[Y]: " .. text );	

end
TS.ChatCmd( "/y", yell );
TS.ChatCmd( "/yell", yell );

local function whisper( ply, cmd, text )

	ply:WhisperLocalChat( "[w]: " .. text );

end
TS.ChatCmd( "/w", whisper );
TS.ChatCmd( "/whisper", whisper );

local function event( ply, cmd, text )

	if( not ply:IsEvent() or not ply:IsAdmin() ) then return; end
	
	for k, v in pairs( player.GetAll() ) do
		umsg.Start( "msgEv", v );
			umsg.String( "(Event)" .. text );
		umsg.End();	
	end
	
end
TS.ChatCmd( "/event", event );
TS.ChatCmd( "/ev", event );

local function advert( ply, cmd, text )

	PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") advertised" )
	
	for k, v in pairs( player.GetAll() ) do
		umsg.Start( "msgAdv", v );
			umsg.String( "*** [ADVERT]:" .. text .. " ***"  );
		umsg.End();	
	end
	
end
TS.ChatCmd( "/adv", advert );
TS.ChatCmd( "/advert", advert );

local function dispatch( ply, cmd, text )

	if( not ply:IsCombine() ) then return; end
	
	PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") sent out a dispatch" )
	ply:Dispatch( text )

	
end
TS.ChatCmd( "/dp", dispatch );
TS.ChatCmd( "/dispatch", dispatch );

local function broadcast( ply, cmd, text )

	if( not ply:IsCA() ) then
		Console( ply, "Need to be CA!", true )
		return 
	end	
	
	PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") broadcasted" )
	
	ply:Broadcast( text )
	ply:SayLocalChat( text )
	
end
TS.ChatCmd( "/bc", broadcast );
TS.ChatCmd( "/broadcast", broadcast );

local function looc( ply, cmd, text )

	ply:SayLocalOOCChat( "[LOCAL-OOC] " .. text );

end
TS.ChatCmd( "/looc", looc );
TS.ChatCmd( "[[", looc );
TS.ChatCmd( ".//", looc );	

local function me( ply, cmd, text )

	ply:DoICAction( text );

end
TS.ChatCmd( "/me", me );

local function tapdance( ply, cmd, text )

	ply:DoICAction( " tap dances" );

end
TS.ChatCmd( "/tapdance", tapdance );

local function write( ply, cmd, text )

	local res, i, x, y = ply:HasItem( "paper" );
	
	if( res ) then

		ply:GetTable().SelectedPaper = { Inv = i, x = x, y = y };

		umsg.Start( "LWP", ply );
			umsg.String( text );
		umsg.End();
		
	end

end
TS.ChatCmd( "/write", write );

local function adminmsg( ply, cmd, text )

	for k, v in pairs( player.GetAll() ) do
		
		if( v:CanUseCommand() ) then

			umsg.Start( "AdminMessage", v );
				umsg.String( ply:GetRPName() .. " (" .. ply:Nick() .. ") to admins:" .. text );
			umsg.End();

			--v:PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") to admins:" .. text );

		end

	end
	
	if( not ply:CanUseCommand() ) then
		
		umsg.Start( "AdminMessage", ply );
			umsg.String( ply:GetRPName() .. " (" .. ply:Nick() .. ") to admins:" .. text );
		umsg.End();

		---ply:PrintMessage( 2, ply:GetRPName() .. " (" .. ply:Nick() .. ") to admins:" .. text );
		
	end
	
end
TS.ChatCmd( "!a", adminmsg );
TS.ChatCmd( "/admin", adminmsg );
TS.ChatCmd( "!admin", adminmsg );

local function pm( ply, cmd, text )

	if( not string.find( text, " " ) or not string.find( string.sub( text, string.find( text, " " ) + 1 ), " " ) ) then return; end

	local namepos = string.find( text, " " ) + 1;
	local msgpos = string.find( string.sub( text, string.find( text, " " ) + 1 ), " " );

	local name = string.sub( text, namepos, msgpos );
	text = string.sub( text, msgpos + 1 );
	
	local succ, result = TS.FindPlayerByName( name );
	TS.ErrorMessage( ply, true, succ, result );
	
	if( succ ) then
	
		umsg.Start( "PrivateMessage", ply );
			umsg.String( "[PM TO " .. result:GetRPName() .. "]" .. text );
		umsg.End();
		
		umsg.Start( "PrivateMessage", result );
			umsg.String( "[PM FROM " .. ply:GetRPName() .. "]" .. text );
		umsg.End();
		
		ply:PrintMessage( 2, "[PM TO " .. result:GetRPName() .. "]" .. text );
		result:PrintMessage( 2, "[PM FROM " .. ply:GetRPName() .. "]" .. text );
	
	end

end
TS.ChatCmd( "/pm", pm );

local function it( ply, cmd, text )

	ply:SayICAction( text );

end
TS.ChatCmd( "/it", it );

local function lean( ply, cmd, text )

	if( ply:IsCombineDefense() ) then return; end
	ply:ConCommand( "rp_ic_lean\n" );
	
end
TS.ChatCmd( "/lean", lean );

local function sitground( ply, cmd, text )

	if( ply:IsCombineDefense() ) then return; end
	ply:ConCommand( "rp_ic_sitground\n" );
	
end
TS.ChatCmd( "/sitground", sitground );

local function stand( ply, cmd, text )

	if( ply:IsCombineDefense() ) then return; end
	if( ply:GetTable().InStanceAction ) then
		if( ply:GetTable().StanceGroundSit ) then
			ply:ConCommand( "rp_ic_sitground\n" );
		elseif( ply:GetTable().StanceSit  ) then
			ply:ConCommand( "rp_ic_sit\n" );
		end
	end
	
end
TS.ChatCmd( "/stand", stand );

local function sit( ply, cmd, text )

	if( ply:IsCombineDefense() ) then return; end
	ply:ConCommand( "rp_ic_sit " .. text .. "\n" );
	
end
TS.ChatCmd( "/sit", sit );

local function atw( ply, cmd, text )

	if( ply:IsCombine() ) then return; end
	ply:ConCommand( "rp_ic_atw " .. text .. "\n" );
	
end
TS.ChatCmd( "/atw", atw );

local function scannertoggle( ply, cmd, text )

	if( not ply:IsCombine() ) then return; end
	
	local already = false
	for k, v in pairs( scnr.plyr ) do
		if v[1] == ply then
			already = true
		end
	end
	
	if already then
		ply:ConCommand( "eng_stopscanner\n" );
	else
		ply:ConCommand( "eng_scanner\n" );
	end

end
TS.ChatCmd( "/scanner", scannertoggle );

local VGSfx = 
{ 
	"vo/npc/vortigaunt/vortigese02.wav",
	"vo/npc/vortigaunt/vortigese03.wav",
	"vo/npc/vortigaunt/vortigese04.wav",
	"vo/npc/vortigaunt/vortigese05.wav",
	"vo/npc/vortigaunt/vortigese07.wav",
	"vo/npc/vortigaunt/vortigese08.wav",
	"vo/npc/vortigaunt/vortigese09.wav",
	"vo/npc/vortigaunt/vortigese11.wav",
	"vo/npc/vortigaunt/vortigese12.wav",
	"vo/npc/vortigaunt/vortigese13.wav",
}

local VGSfxText =
{
	"Aarrr Gla'hhh!",
	"Darr'ahhh.",
	"Doooottt.",
	"Lawnnng'ahh.",
	"Dawnghh'ahh!",
	"Gawlah'ahh!",
	"Daleh'Long!",
	"Juuurrr. Alleng'Jer, Alle Gan.",
	"Jurrrr, lonnn gawn... Shalah grahhh.",
	"Turrrr, lonn gurrr. Challlah chur. Gownnnn, Gon... Luuuuuuuuuur.",
}
	
local function vortigese( ply, cmd, text )
	
	if( ply:GetPlayerFaction() == "Vort" ) then
	
		local wtftoplay = math.random( 1, table.getn(VGSfx) );
	
		ply:EmitSound( Sound( VGSfx[wtftoplay] ) );
		ply:DoICAction( " says, \"" .. VGSfxText[wtftoplay] .. "\" to his kin, only they understand it." );
	
		ply:VortLocalChat( text );
		
	end	
	
end
TS.ChatCmd( "/v", vortigese );

--[[Barrier Shizzle]]--
function BarrierType(ply, cmd, text)
	if( !ply:IsCombineDefense() ) then return end
	
	local num = tonumber( text );
	
	if num then
		barriertype = num;
		Console(ply, "[Shield Barrier] The barrier type has been set to ".. num ..".", true);
	else
		Console(ply, "[Shield Barrier] Please enter a number that is either 1 or 2.", true);
	end
end
TS.ChatCmd( "!barriertype", BarrierType );

function BarrierMake(ply, cmd, text)
	
	if( !ply:IsCombineDefense() ) then return end
	
	local trace = ply:GetEyeTrace();
	
	local first_vec = nil;
	local second_vec = nil;
	
	if !barrierStep or barrierStep == 2 then
		barrierStep = 1
		barrierpos = trace.HitPos
		Console(ply, "[Shield Barrier] Got first vector (".. tostring(trace.HitPos) ..")", true);
	else
		local firstpos  = barrierpos
		local secondpos = trace.HitPos
		
		local barrier = ents.Create("ts2_barrier");
		barrier:SetPos( barrierpos );
		
		if( barriertype )then
			Msg("(CMD) (".. type(barriertype) ..") Barrier Type: ".. barriertype .."\n");
			barrier:SetKeyValue( "type", barriertype );
		end
		
		barrier:SetNWVector( "MinVec", firstpos );
		barrier:SetNWVector( "MaxVec", secondpos );
		barrier:SetOwner( ply );
		barrier:Spawn();
		
		undo.Create("bam_barrier");
			undo.SetPlayer( ply );
			undo.AddEntity( barrier );
		undo.Finish();
		
		barrierStep = 2;
		
		Console(ply, "[Shield Barrier] Barrier has been made.", true);
	end
end
TS.ChatCmd( "!barrier", BarrierMake );

function GiveIDCard( ply, cmd, text )

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
		
		local plur = "s";
		
		if( val == 1 ) then
			plur = "";
		end
	
		umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " gave you their ID Card." );
		umsg.End();	

		umsg.Start( "GIDC", tr.Entity );
			umsg.Short( ply:GetNWFloat( "CID" ) );
			umsg.String( ply:GetRPName() );
			umsg.String( ply:GetModel() );
			umsg.Short( ply:GetPlayerAge() );
			umsg.Short( ply:GetNWFloat( "CID" ) );
			umsg.String( ply:GetPlayerClassMark() );
		umsg.End();
		
	--[[	umsg.Start( "ICAction", ply );
			umsg.String( "You" );
			umsg.String( " gave " .. tr.Entity:GetRPName() .. " your ID Card." );
		umsg.End();	--]]
		
		TS.CreateWhiteNotify( ply, "You gave " .. tr.Entity:GetRPName() .. " your CID Card" )
	
	end
end
concommand.Add( "giveid", GiveIDCard );
TS.ChatCmd( "/giveid", GiveIDCard );

function GrabIDCard( ply, cmd, text )

	if( not ply:IsCombineDefense() ) then return; end

	if( not ply:Alive() or not ply:GetPlayerConscious() ) then
		return;
	end
	
	local trace = { }
	trace.start = ply:EyePos();
	trace.endpos = trace.start + ply:GetAimVector() * 90;
	trace.filter = ply;
	
	local tr = util.TraceLine( trace );
	
	if( tr.Entity and tr.Entity:IsValid() and tr.Entity:IsPlayer() ) then
		
		local plur = "s";
		
		if( val == 1 ) then
			plur = "";
		end
	
		umsg.Start( "ICAction", tr.Entity );
			umsg.String( ply:GetRPName() );
			umsg.String( " took your ID Card." );
		umsg.End();	

		umsg.Start( "GIDC", ply );
			umsg.Short( tr.Entity:GetNWFloat( "CID" ) );
			umsg.String( tr.Entity:GetRPName() );
			umsg.String( tr.Entity:GetModel() );
			umsg.Short( tr.Entity:GetPlayerAge() );
			umsg.Short( tr.Entity:GetNWFloat( "CID" ) );
			umsg.String( tr.Entity:GetPlayerClassMark() );
		umsg.End();
		
		--[[umsg.Start( "ICAction", ply );
			umsg.String( "You" );
			umsg.String( " took " .. tr.Entity:GetRPName() .. "'s ID." );
		umsg.End();	--]]
		
		TS.CreateWhiteNotify( ply, "You took " .. tr.Entity:GetRPName() .. " your CID Card" )
	
	end
end
concommand.Add( "grabid", GrabIDCard );
TS.ChatCmd( "/grabid", GrabIDCard );

function GoRebelClothes( ply, cmd, text )

	if( ply:HasInventory( "Rebel Vest" ) ) then
	
		local model = string.lower( ply:GetModel() )
		model = string.gsub( model, "group03m", "group03" );
		model = string.gsub( model, "group02", "group03" );
		model = string.gsub( model, "group01", "group03" );
		
		ply:SetModel( model )
		
	else	
	
		ply:PrintMessage( 3, "You don't have a vest" )
		
	end

end
TS.ChatCmd( "/clothes", GoRebelClothes )	

local function GoCWU( ply, cmd, text )

	if( ply:HasInventory( "CWU Clothing" ) ) then
	
		local model = string.lower( ply:GetModel() )
		model = string.gsub( model, "humans/group03m", "barnes/refugee" )
		model = string.gsub( model, "humans/group03", "barnes/refugee" )
		model = string.gsub( model, "humans/group02", "barnes/refugee" )
		model = string.gsub( model, "humans/group01", "barnes/refugee" )
		
	
		ply:SetModel( model )
		
	else

		ply:PrintMessage( 3, "You don't have CWU Clothing!" )
		
	end	
	
end
TS.ChatCmd( "/cwu", GoCWU )	
		
local function GoCitizenClothes( ply, cmd, text )

	if( ply:HasInventory( "Rebel Vest" ) or ply:HasInventory( "Rebel Medic Vest" ) or ply:HasInventory( "CWU Clothing" ) or ply:HasInventory( "Citizens Jacket" ) ) then
	
		local model = string.lower( ply:GetModel() )
		model = string.gsub( model, "group03m", "group01" )
		model = string.gsub( model, "group03", "group01" )
		
		ply:SetModel( model )
		
	end	
	
end	
TS.ChatCmd( "/citizenclothes", GoCitizenClothes )	

local function GoC8Jacket( ply, cmd, text )

	if( ply:HasInventory( "Citizens Jacket" ) ) then
	
		local model = string.lower( ply:GetModel() )
		model = string.gsub( model, "humans/group03m", "barnes/citizen" )
		model = string.gsub( model, "humans/group03", "barnes/citizen" )
		model = string.gsub( model, "humans/group02", "barnes/citizen" )
		model = string.gsub( model, "humans/group01", "barnes/citizen" )
		
	
		ply:SetModel( model )
		
	else

		ply:PrintMessage( 3, "You don't have CWU Clothing!" )
		
	end	
	
end
TS.ChatCmd( "/jacket", GoC8Jacket )		